package com.jy.adscm.operation.mscyb.controller;


import com.baomidou.mybatisplus.plugins.Page;
import com.jy.adscm.exception.AdscmSystemException;
import com.jy.adscm.operation.mscyb.bean.JqylMaterialdetail;
import com.jy.adscm.operation.mscyb.bean.JqylMaterialdetailReback;
import com.jy.adscm.operation.mscyb.bean.QueryJqylMaterialdetailReback;
import com.jy.adscm.operation.mscyb.service.JqylMaterialdetailRebackService;
import com.jy.adscm.operation.mscyb.service.JqylMaterialdetailService;
import com.jy.adscm.security.utils.Token;
import com.jy.adscm.support.SimpleCoreResponse;
import com.jy.adscm.utils.AdscmBaseUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zyl
 * @since 2019-09-10
 */
@RestController
@RequestMapping("/adscm/operation/jqylMaterialdetailReback")
public class JqylMaterialdetailRebackController {
    @Autowired
    JqylMaterialdetailRebackService jqylMaterialdetailRebackService;
    @Autowired
    RedisTemplate<Object, Token> tokenRedisTemplate;
    @RequestMapping("update")
    public SimpleCoreResponse insert(@RequestBody JqylMaterialdetailReback jqylMaterialdetailReback, HttpServletRequest request) throws AdscmSystemException {
        String tokenId = request.getParameter("tokenId");
        Token token = AdscmBaseUtils.getInstance().getTokenByTokenId(tokenId, tokenRedisTemplate);
        boolean insert = jqylMaterialdetailRebackService.updateJqylMaterialdetailReback(jqylMaterialdetailReback,token);
        return new SimpleCoreResponse("200","修改成功",insert);
    }
    @RequestMapping("select")
    public SimpleCoreResponse select(@RequestBody QueryJqylMaterialdetailReback queryJqylMaterialdetailReback, HttpServletRequest request) throws AdscmSystemException {
        Page<JqylMaterialdetailReback> page=new Page(queryJqylMaterialdetailReback.getCurrentPage(),queryJqylMaterialdetailReback.getPageSize());
        page= jqylMaterialdetailRebackService.select(page,queryJqylMaterialdetailReback);
        return new SimpleCoreResponse("200","查询成功",page);
    }
}

